### 获取水平分量：
import pandas as pd
import os
# test:

path = r'D:\work_files\projcet\generation_hour\phour_easy_report\PVreport\summery\standard\统一备份'
save_path = r'D:\work_files\projcet\generation_hour\phour_easy_report\PVreport\summery\standard\统一备份\res\水平分量'
filelists = os.listdir(path)
province = []
for file in filelists:
    if file.endswith('.xlsx'):
        # print(file)
        df = pd.read_excel(os.path.join(path, file))
        prov = df['省'].values[0]
        if prov in province:
            continue
        df['校准经纬度lon'] = df['校准经纬度lon'].round(2)
        df['校准经纬度lat'] = df['校准经纬度lat'].round(2)
        if len(df['校准经纬度lon'].unique()) != 0 or df['校准经纬度lon'].unique().values[0] != 0 \
                or len(df['校准经纬度lat'].unique()) != 0 or df['校准经纬度lat'].unique().values[0] != 0:
            print(f'{file}需要校准经纬度！！！')
            continue
        save_columns_name = ['省', '市', '区/县', 'lon_x', 'lat_x', '面积', 'year_GHI', 'year_DHI'] + [f'Month{i}_GHI' for i in range(1,13)] +\
                            [f'Month{i}_GHI' for i in range(1,13)]
        ghi_save = df[save_columns_name]
        province.append(df['省'].values[0])
        ghi_save.to_excel(os.path.join(save_path, f'{prov}.xlsx'), index=False)

